package com.digital.welcome.controller;


import com.digital.welcome.annotation.OperationLog;
import com.digital.welcome.entity.Application;
import com.digital.welcome.service.ApplicationService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @author 韩
 */
@RestController
@RequestMapping("/application")
public class ApplicationController {

    @Autowired
    private ApplicationService applicationService;

    @ApiOperation("报名信息查询")
    @RequestMapping(value = "/select", method = RequestMethod.GET)
    public String getApplication(@RequestParam(value = "userName") String userName) {
        return applicationService.getApplication(userName);
    }

    @OperationLog()
    @ApiOperation("报名")
    @RequiresPermissions("doApplication")
    @RequestMapping(value = "/do", method = RequestMethod.POST)
    public String doApplication(@RequestBody Application application) {
        return  applicationService.doApplication(application);
    }

    @ApiOperation("获取应报名人数")
    @RequestMapping(value = "/get-all", method = RequestMethod.GET)
    public String getAll() {
        return applicationService.getAll();
    }

    @ApiOperation("获取已报名人数")
    @RequestMapping(value = "/get-number", method = RequestMethod.GET)
    public String getNumber() {
        return applicationService.getNumber();
    }

    @ApiOperation("获取所有已报到学生")
    @RequestMapping(value = "/get-students", method = RequestMethod.GET)
    public String getStudents() {
        return applicationService.getStudents();
    }

    @ApiOperation("获取所有未报到学生")
    @RequestMapping(value = "/get-n-students", method = RequestMethod.GET)
    public String getNStudents() {
        return applicationService.getNStudents();
    }

    @ApiOperation("获取某学院已报到学生")
    @RequestMapping(value = "/get-college-students", method = RequestMethod.GET)
    public String getCollegeStudents(String college) {
        return applicationService.getCollegeStudents(college);
    }

    @ApiOperation("获取某学院未报到学生")
    @RequestMapping(value = "/get-college-n-students", method = RequestMethod.GET)
    public String getCollegeNStudents(String college) {
        return applicationService.getCollegeNStudents(college);
    }

    @ApiOperation("是否报到")
    @RequestMapping(value = "/confirm", method = RequestMethod.GET)
    public String confirm(@RequestParam("学号") String userName) {
        return applicationService.selectConfirm(userName);
    }

}
